package ru.algorithm.clusterization.cftree2;

/**
 * Yuri Zemlyanskiy <urikz@yandex-team.ru>
 * Date: 05.05.2011
 */
public abstract class AbstractCFInnerNode extends AbstractCFNode {

    private final int maximalChildrenNumber;
    private int n = 0;
    private double[] sumX;
    private double[] sumX2;

    public AbstractCFInnerNode(int maximalChildrenNumber) {
        this.maximalChildrenNumber = maximalChildrenNumber;
    }

    @Override
    public int getPointNumber() {
        return n;
    }

    @Override
    public double[] getSum() {
        return sumX;
    }

    @Override
    public double[] getSum2() {
        return sumX2;
    }

    abstract void insert(CFLeaf leaf);
}


//    protected boolean addChildren(AbstractCFNode... children) {
//        boolean result = true;
//        for (final AbstractCFNode node : children) {
//            result = result && addChild(node);
//        }
//        return result;
//    }
//
//    protected boolean addChild(AbstractCFNode child) {
//        if (n == 0) {
//            sumX = Arrays.copyOf(child.getSum(), child.getSum().length);
//            sumX2 = Arrays.copyOf(child.getSum2(), child.getSum2().length);
//        } else {
//            for (int i = 0; i < sumX.length; i++) {
//                sumX[i] += child.getSum()[i];
//                sumX2[i] += child.getSum2()[i];
//            }
//        }
//        children.add(child);
//        return (children.size() < maximalChildrenNumber);
//    }
//
//    public List<AbstractCFNode> getChildren() {
//        return children;
//    }
